<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>08.循环语句</title>
</head>

<body>
    <script>
        /**
         * 循环： do...while。。。
         *       while 循环 
         *       for 循环
         * 
         * break: 结束当前循环
         * break + 别名
         * continue： 结束本次循环
         */
        // 求  1 + 2 + 100
        var sum = 0;
        var count = 1;

        do {
            sum += count;
            count++;
        } while (count <= 100);
        console.log(sum);

        sum = 0;
        count = 1;
        while (count <= 100) {
            sum += count;
            count++;
        }
        console.log(sum);

        // for 循环
        sum = 0;
     
        for(count = 1;count<= 100;count++) {
            sum += count;
         
        }
        console.log(sum);
        
         sum = 0;
         count = 1;
         T:while (true) {
            sum += count;
            if(count  === 100) {
                break T;
            }
            count++;
         }
         console.log(sum);

         // 获取1 - 100 所有的奇数
         sum = 0;
         count = 1;
         while (true) {
            if(!(count % 2)) {
                count++;
                continue;
            }
            console.log(count);
            if(count  >= 99) {
                break;
            }
            count++;
         }
         console.log(sum);
    </script>

</body>

</html>